<template>
	<MyPage title="设置" :isback="true">
		<view slot="gBody"> 
			<view class="my-content">
				<u-cell-group class="list-group">
					<u-cell-item title="修改密码" @click="$utils.navigateTo('/login/retrieve-password',{titleType:'修改'})"></u-cell-item>
					<u-cell-item title="关于我们" @click="$utils.navigateTo('/agreement/agreement',{id:1})"></u-cell-item>
					<u-cell-item title="与我们联系" @click="$utils.navigateTo('/agreement/agreement',{id:50})"></u-cell-item>
					<u-cell-item title="系统权限管理" @click="$utils.navigateTo('/my/auth')"></u-cell-item>
					<u-cell-item title="注销账号" @click="popShow=true"></u-cell-item>
				</u-cell-group>
				<u-button type="error" shape="circle" :plain="true" class="btn" @click="logout">退出登录</u-button>
			</view>
			<!-- 注销账号-弹框 -->
			<u-modal
				v-model="popShow"
				:show-cancel-button="true"
				:mask-close-able="true"
				content="注销账号后将删除一切相关数据，且无法恢复，确定要删除当前账号吗？"
				@confirm="withdraw"
			></u-modal>
		</view>
	</MyPage>
</template>		

<script>
import mixin from "@/libs/mixin.js";
import { delUser,logout } from '@/api/my.js'
export default {
	mixins: [mixin],
	data() {
		return {
			popShow:false
		}
	},
	methods: {
		//注销账号
		withdraw(){
			delUser().then(res=>{
				this.$store.commit('LOGOUT');
				this.$utils.redirectTo('/login/phone-login');
			}).catch(err=>{
				uni.showToast({
					title: err.msg,
					icon:'none'
				})
			});
		},
		//退出登录
		logout(){
			logout().then(res=>{
				this.$store.commit('LOGOUT');
				this.$utils.redirectTo('/login/phone-login');
			}).catch(err=>{
				uni.showToast({
					title: err.msg,
					icon:'none'
				})
			});
		}
	}
}
</script>

<style lang="scss" scoped>
.list-group{
	/deep/ .u-border-top:after{
		border-top:none;
	}
	/deep/ .u-cell{
		padding-left:0;
		padding-right:0;
		.u-cell_title{
			font-size:32rpx;
			color: #333;
		}
	}
}
.btn{
	position:fixed;
	left:5%;
	bottom:50rpx;
	width:90%;
	color: #dd1010 !important;
	border-color: #B00E0E !important;
}
</style>